﻿
create FUNCTION  [dbo].[Get_UDFA_Parameter]
(
    @List nvarchar(2000),--要分隔的字符串
    @SplitOn nvarchar(5),--分隔符
    @num1 int
) 
RETURNS varchar(50)
as
BEGIN
declare @i int,
		@j int,
		@p int,
		@num int,
		@aa Varchar(200)
 
	Set @i=0
	Set @j=len(@SplitOn)
	Set @p=0 
	While LEN(@List) > 0
	Begin
		Set @p = CHARINDEX(@SplitOn,@List)
		if @p > 0
		begin
			set @aa = SUBSTRING(@List,1,@p - 1)
			set @List= SUBSTRING(@List,@p + @j, LEN(@List))
		end
		else
		begin
			set @aa = @List
			set @List= ''
		end
		set @i = @i + 1
		
		If @i=@num1
		Begin
			break
		End	
		else
			set @aa= ''
		
	End
return @aa	

end	

